13. Car Class
How does Python know about the Car object?
Well, there is a file named car.py
(car with a lowercase ‘c’), and inside this file is something new. A class Car, with an uppercase ‘C’.
This class allows us to write code like car.Car()
, which calls a special function: __init__
that's defined in our Car class.
__init__
__init__
stands for initialize and this function frees up memory and allows us to create a specific Car object, which we called carla
. carla
can then access all of the functions that are inside the Car class like move()
and turn_left()
and the initialization means that a computer now has the space to remember what this car object can do and what state it is in at any given moment.
Next, let’s look closer at this class file!